// erp订单退换货详情
var app = getApp();
import {
  api
} from '../../../../js/util'
import {
  orderlist
} from "../../../../js/modules/order.js"
import {
  alert,
  isEmpty
} from '../../../../js/newUtil';
const pageBehavior = require('../../../../js/common/PageBehavior')
import { config } from "../../../../js/modules/gloab.js";

Page({
  behaviors: [pageBehavior],
  pageKey: "orderOffineRetreat",
  /**
   * 页面的初始数据
   */
  data: {
    imgDomain: api.imgDomain,
    enableOss: api.enableOss,
    oddNumber: '',
    detailList: {},
    headerBg: "",
    Currency: '', //货币符号
    quantityDigits: 2, // 数量显示小数位数
    priceDigits: 2, // 价格显示小数位数
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      oddNumber: options.oddNumber
    })
    this.getConfig()
    this.loadList();
  },
  loadList() {
    var that = this;
    var param = {
      PageIndex: 1,
      PageSize: 6,
      keywords: that.data.oddNumber
    };
    orderlist.getOfflineRetreatinfo(param).then((res) => {
      let data = res.data
      for (var i = 0; i < data.length; i++) {
        if (data[i].OrderCode == that.data.oddNumber) {
          that.setData({
            detailList: data[i]
          });
        }
      }
      if (isEmpty(data)) {
        alert({
          content: '未获取到信息',
          success() {
            wx.navigateBack()
          }
        })
      }
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.setData({
      headerBg: api.titleColor || "#e56b14",
      Currency: api.Currency || '￥'
    })
  },

  getConfig () {
    let that = this
    let fkid = app.dns.proprietorId
    let fkflag = app.dns.proprietor
    config.getWholesaleConfigs(
    fkid,
    fkflag,
    'Wholesale',
      (model)=> {
        that.setData({
          quantityDigits: model.QuantityDigits,
          priceDigits: model.PriceDigits
        })
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  }
})